Release 10.1A: OpenEdge Development:
Progress 4GL Reference


CREATE DATABASE statement

Creates a new OpenEdge database.

Syntax

CREATE DATABASE new-database [ FROM old-database [ NEW-INSTANCE ] ]
  [ REPLACE ] [ NO-ERROR ] 

new-database

A CHARACTER expression that returns the full or relative pathname of the database you want to create. If the database already exists, a new database is not created unless you specify REPLACE.

FROM old-database

A CHARACTER expression that returns the name of the database whose schema and data you want to copy to the new database. The value of old-database can be a full or relative pathname or one of the special strings "EMPTY", "DEMO", or "SPORTS". If you omit this option, Progress creates an empty database.

NEW-INSTANCE

If specified, Progress assigns the new database a new globally unique identifier (GUID) value as the database identifier. If not specified, Progress assigns the new database the same GUID database identifier as the old database.

When you create a new database by copying an existing 10.1A database provided by Progress (such as the empty database, demo database, or Sports database), Progress always assigns the new database a new GUID database identifier.

Note: Use this option only when creating a new 10.1A database by copying an existing 10.1A database.

REPLACE

If specified and a database already exists with the name specified by new-database, the existing database is deleted and replaced with the new database. If not specified and a database already exists with the name specified by new-database, an error occurs.

NO-ERROR

If specified and the CREATE DATABASE statement fails, the error condition is not raised.

Example

This procedure prompts for the name of a database to connect. If the database does not exist, the procedure creates it.

r-credb.p
DEFINE VARIABLE dbname AS CHARACTER LABEL "Database" FORMAT "x(65)".

/* Prompt the user for the name of a demo database to connect. */
SET dbname HELP "Enter the name of your database."
    WITH FRAME dbname-frame SIDE-LABELS.

/* If the entered name does not have the .db suffix, add it.
   This is necessary for the search function to work correctly. */
IF LENGTH(dbname) < 3
THEN dbname = dbname + ".db".
ELSE IF SUBSTR(dbname, LENGTH(dbname) - 2) = ".db"
     THEN dbname = dbname + ".db".

/* If the database does not exist, create it from SPORTS. */
IF SEARCH(dbname) = ?
THEN DO:
  MESSAGE "Database does not exist. Do you want to create it?"
     VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO TITLE "Connect Database"
       UPDATE create-it AS LOGICAL.

  IF create-it
  THEN DO:  
    CREATE DATABASE dbname FROM "SPORTS".
    MESSAGE "New database created:" dbname.
  END.
  ELSE UNDO, RETRY.
END.

/* Connect the database. */
CONNECT VALUE(dbname) -1. 

Notes

See also

ALIAS function, CONNECT statement, CONNECTED function, CREATE ALIAS statement, DATASERVERS function, DBCODEPAGE function, DBCOLLATION function, DBRESTRICTIONS function, DBTYPE function, DELETE ALIAS statement, DISCONNECT statement, ERROR-STATUS system handle, FRAME-DB function, LDBNAME function, NUM-DBS function, PDBNAME function, SDBNAME function


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095